﻿//----------------------------------------------------------------------------------------------------
// GameType_Normal, go get the goal node, thats it.
//----------------------------------------------------------------------------------------------------

package HG.GameTypes
{
	import HG.GameService;
	import HG.Managers.GameRuleManager;
	import HG.Managers.LevelManager;
	import HG.Managers.NodeManager;
	
	import HG.Events.NodeEvent;
	
	public class GameType_Normal extends IGameType
	{
		var m_gameRuleManager:GameRuleManager;
		var m_levelManager:LevelManager;
		
		//----------------------------------------------------------------------------------------------------
		public function GameType_Normal()
		{
			m_name = "Standard";
			m_description = "Reach the Goal Node.";
			
			m_gameRuleManager = GameService.GetInstance().GetGameRuleManager();
			m_levelManager = GameService.GetInstance().GetLevelManager();
			
			m_levelManager.addEventListener(NodeEvent.CAPTURE, OnNodeCaptured);
		}
		
		//----------------------------------------------------------------------------------------------------
		public function OnNodeCaptured(evt:NodeEvent)
		{
			if (!m_active)
				return;
				
			if (m_gameRuleManager.GetEditorMode())
				return;
			
			switch (evt.m_node.GetType())
			{
				// Goal node for winning --------------------------------
				case NodeManager.NODE_GOAL:
				{
					m_gameRuleManager.DeclarePlayerFate(GameRuleManager.FATE_VICTORY, evt.m_capBy);
				}break;
			}
		}
		
		//----------------------------------------------------------------------------------------------------
	}
}